/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Volumen.java
 *
 * Created on 12/05/2011, 07:57:40 PM
 */

package proyecto;

/**
 *
 * @author home
 */
public class Volumen extends javax.swing.JFrame {

    /** Creates new form Volumen */
    public Volumen() {
        initComponents();
        buttonGroup1.add(k1);
        buttonGroup1.add(h1);
        buttonGroup1.add(d1);
        buttonGroup1.add(m1);
        buttonGroup1.add(dm1);
        buttonGroup1.add(c1);
        buttonGroup1.add(mm1);
        buttonGroup2.add(k2);
        buttonGroup2.add(h2);
        buttonGroup2.add(d2);
        buttonGroup2.add(m2);
        buttonGroup2.add(dm2);
        buttonGroup2.add(c2);
        buttonGroup2.add(mm2);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jLabel4 = new javax.swing.JLabel();
        h2 = new javax.swing.JRadioButton();
        k1 = new javax.swing.JRadioButton();
        n = new javax.swing.JTextField();
        m1 = new javax.swing.JRadioButton();
        jLabel3 = new javax.swing.JLabel();
        dm2 = new javax.swing.JRadioButton();
        mm1 = new javax.swing.JRadioButton();
        d2 = new javax.swing.JRadioButton();
        dm1 = new javax.swing.JRadioButton();
        jLabel2 = new javax.swing.JLabel();
        d1 = new javax.swing.JRadioButton();
        h1 = new javax.swing.JRadioButton();
        c1 = new javax.swing.JRadioButton();
        c2 = new javax.swing.JRadioButton();
        jLabel1 = new javax.swing.JLabel();
        resu = new javax.swing.JTextField();
        k2 = new javax.swing.JRadioButton();
        mm2 = new javax.swing.JRadioButton();
        m2 = new javax.swing.JRadioButton();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();

        jLabel4.setText("Resultado:");

        h2.setText("Hm3");

        k1.setText("Km3");

        m1.setText("M3");

        jLabel3.setText("Convertir a:");

        dm2.setText("Dm3");

        mm1.setText("Mm3");

        d2.setText("Dam3");

        dm1.setText("Dm3");

        jLabel2.setText("Ingresar:");

        d1.setText("Dam3");

        h1.setText("Hm3");

        c1.setText("Cm3");

        c2.setText("Cm3");

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(0, 0, 255));
        jLabel1.setText("Volumen:");

        k2.setText("Km3");

        mm2.setText("Mm3");

        m2.setText("M3");

        jButton1.setText("Ok");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Limpiar");
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton2MouseClicked(evt);
            }
        });

        jLabel5.setText("De:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(resu, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(51, 51, 51)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(183, 183, 183)
                                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(k1)
                                    .addComponent(h1)
                                    .addComponent(d1)
                                    .addComponent(m1)
                                    .addComponent(dm1)
                                    .addComponent(c1)
                                    .addComponent(mm1)
                                    .addComponent(jLabel5))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 172, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(k2)
                                    .addComponent(h2)
                                    .addComponent(d2)
                                    .addComponent(m2)
                                    .addComponent(dm2)
                                    .addComponent(c2)
                                    .addComponent(mm2)))
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jLabel2)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGap(1, 1, 1)
                                .addComponent(jLabel1)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(n, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(89, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(n, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(4, 4, 4)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(k1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(h1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(d1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(m1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(dm1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(c1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(mm1))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(k2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(h2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(d2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(m2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(dm2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(c2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(mm2)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(resu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(12, 12, 12)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addGap(24, 24, 24))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    /*
     * @ duuble num, res;
     */
    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
        // TODO add your handling code here:
        double num=Double.parseDouble(n.getText());
    double res;
    if (mm1.isSelected()&&mm2.isSelected()){
    resu.setText(String.valueOf(num));
    }
    if  (mm1.isSelected()&&c2.isSelected()){
    res=num*0.1;
    resu.setText(String.valueOf(res));
    }
    if  (mm1.isSelected()&&dm2.isSelected()){
    res=num*0.001;
    resu.setText(String.valueOf(res));
    }
    if (mm1.isSelected()&&m2.isSelected()){
    res=num*0.0001;
    resu.setText(String.valueOf(res));
    }
    if  (mm1.isSelected()&&d2.isSelected()){
    res=num*0.00001;
    resu.setText(String.valueOf(res));
    }
    if  (mm1.isSelected()&&h2.isSelected()){
    res=num*0.000001;
    resu.setText(String.valueOf(res));
    }
    if (mm1.isSelected()&&k2.isSelected()){
    res=num*0.0000001;
    resu.setText(String.valueOf(res));
    }
    if (c1.isSelected()&&mm2.isSelected()){
    res=num/0.1;
    resu.setText(String.valueOf(res));
    }
    if  (c1.isSelected()&&c2.isSelected()){
    resu.setText(String.valueOf(num));
    }
    if  (c1.isSelected()&&dm2.isSelected()){
    res=num*0.1;
    resu.setText(String.valueOf(res));
    }
    if (c1.isSelected()&&m2.isSelected()){
    res=num*0.01;
    resu.setText(String.valueOf(res));
    }
    if  (c1.isSelected()&&d2.isSelected()){
    res=num*0.001;
    resu.setText(String.valueOf(res));
    }
    if  (c1.isSelected()&&h2.isSelected()){
    res=num*0.0001;
    resu.setText(String.valueOf(res));
    }
    if (c1.isSelected()&&k2.isSelected()){
    res=num*0.00001;
    resu.setText(String.valueOf(res));
    }
    if (dm1.isSelected()&&mm2.isSelected()){
    res=num/0.01;
    resu.setText(String.valueOf(res));
    }
    if  (dm1.isSelected()&&c2.isSelected()){
    res=num/0.1;
    resu.setText(String.valueOf(res));
    }
    if  (dm1.isSelected()&&dm2.isSelected()){
    resu.setText(String.valueOf(num));
    }
    if (dm1.isSelected()&&m2.isSelected()){
    res=num*0.1;
    resu.setText(String.valueOf(res));
    }
    if  (dm1.isSelected()&&d2.isSelected()){
    res=num*0.01;
    resu.setText(String.valueOf(res));
    }
    if  (dm1.isSelected()&&h2.isSelected()){
    res=num*0.001;
    resu.setText(String.valueOf(res));
    }
    if (dm1.isSelected()&&k2.isSelected()){
    res=num*0.0001;
    resu.setText(String.valueOf(res));
    }
    if (m1.isSelected()&&mm2.isSelected()){
    res=num/0.001;
    resu.setText(String.valueOf(res));
    }
    if  (m1.isSelected()&&c2.isSelected()){
    res=num/0.01;
    resu.setText(String.valueOf(res));
    }
    if  (m1.isSelected()&&dm2.isSelected()){
    res=num/0.1;
    resu.setText(String.valueOf(res));
    }
    if (m1.isSelected()&&m2.isSelected()){
    resu.setText(String.valueOf(num));
    }
    if  (m1.isSelected()&&d2.isSelected()){
    res=num*0.1;
    resu.setText(String.valueOf(res));
    }
    if  (m1.isSelected()&&h2.isSelected()){
    res=num*0.01;
    resu.setText(String.valueOf(res));
    }
    if (m1.isSelected()&&k2.isSelected()){
    res=num*0.001;
    resu.setText(String.valueOf(res));
    }
    if (d1.isSelected()&&mm2.isSelected()){
    res=num/0.0001;
    resu.setText(String.valueOf(res));
    }
    if  (d1.isSelected()&&c2.isSelected()){
    res=num/0.001;
    resu.setText(String.valueOf(res));
    }
    if  (d1.isSelected()&&dm2.isSelected()){
    res=num/0.01;
    resu.setText(String.valueOf(res));
    }
    if (d1.isSelected()&&m2.isSelected()){
    res=num/0.1;
    resu.setText(String.valueOf(res));
    }
    if  (d1.isSelected()&&d2.isSelected()){
    resu.setText(String.valueOf(num));
    }
    if  (d1.isSelected()&&h2.isSelected()){
    res=num*0.1;
    resu.setText(String.valueOf(res));
    }
    if (d1.isSelected()&&k2.isSelected()){
    res=num*0.01;
    resu.setText(String.valueOf(res));
    }
    if (h1.isSelected()&&mm2.isSelected()){
    res=num/0.00001;
    resu.setText(String.valueOf(res));
    }
    if  (h1.isSelected()&&c2.isSelected()){
    res=num/0.0001;
    resu.setText(String.valueOf(res));
    }
    if  (h1.isSelected()&&dm2.isSelected()){
    res=num/0.001;
    resu.setText(String.valueOf(res));
    }
    if (h1.isSelected()&&m2.isSelected()){
    res=num/0.01;
    resu.setText(String.valueOf(res));
    }
    if  (h1.isSelected()&&d2.isSelected()){
    res=num/0.1;
    resu.setText(String.valueOf(res));
    }
    if  (h1.isSelected()&&h2.isSelected()){
    resu.setText(String.valueOf(num));
    }
    if (h1.isSelected()&&k2.isSelected()){
    res=num*0.1;
    resu.setText(String.valueOf(res));
    }
    if (h1.isSelected()&&mm2.isSelected()){
    res=num/0.000001;
    resu.setText(String.valueOf(res));
    }
    if  (h1.isSelected()&&c2.isSelected()){
    res=num/0.00001;
    resu.setText(String.valueOf(res));
    }
    if  (h1.isSelected()&&dm2.isSelected()){
    res=num/0.0001;
    resu.setText(String.valueOf(res));
    }
    if (h1.isSelected()&&m2.isSelected()){
    res=num/0.001;
    resu.setText(String.valueOf(res));
    }
    if  (h1.isSelected()&&d2.isSelected()){
    res=num/0.01;
    resu.setText(String.valueOf(res));
    }
    if  (h1.isSelected()&&h2.isSelected()){
    res=num/0.1;
    resu.setText(String.valueOf(res));
    }
    if (h1.isSelected()&&k2.isSelected()){
    resu.setText(String.valueOf(num));
    }
    }//GEN-LAST:event_jButton1MouseClicked

    private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
        // TODO add your handling code here:
     resu.setText("");
     n.setText("");
    }//GEN-LAST:event_jButton2MouseClicked

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Volumen().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JRadioButton c1;
    private javax.swing.JRadioButton c2;
    private javax.swing.JRadioButton d1;
    private javax.swing.JRadioButton d2;
    private javax.swing.JRadioButton dm1;
    private javax.swing.JRadioButton dm2;
    private javax.swing.JRadioButton h1;
    private javax.swing.JRadioButton h2;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JRadioButton k1;
    private javax.swing.JRadioButton k2;
    private javax.swing.JRadioButton m1;
    private javax.swing.JRadioButton m2;
    private javax.swing.JRadioButton mm1;
    private javax.swing.JRadioButton mm2;
    private javax.swing.JTextField n;
    private javax.swing.JTextField resu;
    // End of variables declaration//GEN-END:variables

}
